//
//  IProductTag.m
//  XRmenu
//
//  Created by yangxh on 11-3-24.
//  Copyright 2011 E0571. All rights reserved.
//

#import "IProductTag.h"


@implementation IProductTag

@synthesize checkInTime;
@synthesize Id;
@synthesize keyword;
@synthesize languageEx;
@synthesize productNum;
@synthesize status;
@synthesize tagId;

//=========================================================== 
// - (id)init
//
//=========================================================== 
- (id)init
{
	return [self initWithCheckInTime:nil Id:0 keyword:nil languageEx:nil productNum:0 status:0 tagId:nil];
}


//=========================================================== 
// - (id)initWith:
//
//=========================================================== 
- (id)initWithCheckInTime:(NSDate*)aCheckInTime Id:(NSInteger)anId keyword:(NSString*)aKeyword languageEx:(NSString*)aLanguageEx productNum:(NSInteger)aProductNum status:(NSInteger)aStatus tagId:(NSString*)aTagId 
{
    self = [super init];
    if (self) {
        self.checkInTime = aCheckInTime;
        self.Id = anId;
        self.keyword = aKeyword;
        self.languageEx = aLanguageEx;
        self.productNum = aProductNum;
        self.status = aStatus;
        self.tagId = aTagId;
    }
    return self;
}


//=========================================================== 
// + (id)objectWith:
//
//=========================================================== 
+ (id)objectWithCheckInTime:(NSDate*)aCheckInTime Id:(NSInteger)anId keyword:(NSString*)aKeyword languageEx:(NSString*)aLanguageEx productNum:(NSInteger)aProductNum status:(NSInteger)aStatus tagId:(NSString*)aTagId  
{
    id result = [[[self class] alloc] initWithCheckInTime:aCheckInTime Id:anId keyword:aKeyword languageEx:aLanguageEx productNum:aProductNum status:aStatus tagId:aTagId];
	
    return [result autorelease];
}

//=========================================================== 
// - (NSArray *)keyPaths
//
//=========================================================== 
- (NSArray *)keyPaths
{
    NSArray *result = [NSArray arrayWithObjects:
					   @"checkInTime",
					   @"Id",
					   @"keyword",
					   @"languageEx",
					   @"productNum",
					   @"status",
					   @"tagId",
					   nil];
	
    return result;
}


//=========================================================== 
// - (NSString *)descriptionForKeyPaths
//
//=========================================================== 
- (NSString *)descriptionForKeyPaths 
{
    NSMutableString *desc = [NSMutableString string];
    NSEnumerator *e = [[self keyPaths] objectEnumerator];
    NSString *thisKey;
    [desc appendString:@"\n\n"];
	
    while ((thisKey = [e nextObject])) {
        [desc appendFormat: @"%@: %@\n", thisKey, [self valueForKey:thisKey]];
    }
	
    return [NSString stringWithString:desc];
}

- (NSString *)description
{
	return [self descriptionForKeyPaths];
}

//=========================================================== 
// dealloc
//=========================================================== 
- (void)dealloc
{
    [checkInTime release];
    checkInTime = nil;
    [keyword release];
    keyword = nil;
    [languageEx release];
    languageEx = nil;
    [tagId release];
    tagId = nil;
	
    [super dealloc];
}

+ (IProductTag *)iProductTagByParse:(NSDictionary *)info
{
	IProductTag *tag = [IProductTag objectWithCheckInTime:[NSDate date]
													   Id:dictInt(info,@"ID")
												  keyword:dictObject(info,@"Keyword")
											   languageEx:dictObject(info,@"LanguageId")
											   productNum:dictInt(info,@"ProductNum")
												   status:dictInt(info,@"Status")
													tagId:dictObject(info,@"TagId")];
	return tag;
}

@end
